package com.chenbei.system.util;

import com.chenbei.system.domain.SysOrganization;
import com.chenbei.system.domain.SysUser;
import com.chenbei.system.vo.resp.SysUserSelectorDataResp;

import java.util.ArrayList;
import java.util.List;

public class SysUserSelectorDataRespUtil {

    public static List<SysUserSelectorDataResp> convertSysOrganizations(List<SysOrganization> sysOrganizations) {
        List<SysUserSelectorDataResp> sysUserSelectorDataRespList = new ArrayList<>();
        if (sysOrganizations != null && !sysOrganizations.isEmpty()) {
            for (SysOrganization organization : sysOrganizations) {
                SysUserSelectorDataResp sysUserSelectorDataResp = new SysUserSelectorDataResp();
                sysUserSelectorDataResp.setId(organization.getId());
                sysUserSelectorDataResp.setName(organization.getName());
                sysUserSelectorDataResp.setType(1);

                sysUserSelectorDataRespList.add(sysUserSelectorDataResp);
            }
        }

        return sysUserSelectorDataRespList;
    }

    public static List<SysUserSelectorDataResp> convertSysUsers(List<SysUser> sysUsers) {
        List<SysUserSelectorDataResp> sysUserSelectorDataRespList = new ArrayList<>();
        if (sysUsers != null && !sysUsers.isEmpty()) {
            for (SysUser sysUser : sysUsers) {
                SysUserSelectorDataResp sysUserSelectorDataResp = new SysUserSelectorDataResp();
                sysUserSelectorDataResp.setId(sysUser.getId());
                sysUserSelectorDataResp.setName(sysUser.getNickname());
                sysUserSelectorDataResp.setIcon(sysUser.getAvatar());
                sysUserSelectorDataResp.setType(2);

                sysUserSelectorDataRespList.add(sysUserSelectorDataResp);
            }
        }

        return sysUserSelectorDataRespList;
    }
}
